<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
var numberOfWays = function(startPos, endPos, k) {
    let nums = Array(k).fill(1), target = endPos - startPos,  t = k - target, mod = 1e9 + 7
    if(t < 0 || t % 2) return 0
    t >>= 1 

    let f = Array(t + 1).fill(0)
    f[0] = 1
    for(let i = 1; i <= k; i++){
       for(let j = k; j >= 1; j--){
          f[j] = (f[j] + f[j - 1])%mod
       } 
    }  
    return f[t]
};
</script>
</html>